import http from '@/utils/request'
import defaultSettings from '@/settings'

export function getPage(data) {
  return http.request({
    url: 'ad/FindWithPagerAsync',
    method: 'get',
    params: data,
    baseURL: defaultSettings.apiCmsUrl
  })
}

export function save(data, url) {
  return http.request({
    url: url,
    method: 'post',
    data: data,
    baseURL: defaultSettings.apiCmsUrl
  })
}

export function getDetail(id) {
  return http({
    url: 'ad/GetById?id=' + id,
    method: 'get',
    baseURL: defaultSettings.apiCmsUrl
  })
}

/**
   * 批量设置启用状态
   * @param {id集合} ids
   */
export function setEnable(data) {
  return http({
    url: 'ad/SetEnabledMarktBatchAsync',
    method: 'post',
    params: data,
    baseURL: defaultSettings.apiCmsUrl
  })
}
/**
   * 批量软删除
   * @param {id集合} ids
   */
export function delSoft(data) {
  return http({
    url: 'ad/DeleteSoftBatchAsync',
    method: 'post',
    params: data,
    baseURL: defaultSettings.apiCmsUrl
  })
}

/**
   * 批量删除
   * @param {id集合} ids
   */
export function del(data) {
  return http({
    url: 'ad/DeleteBatchAsync',
    method: 'delete',
    params: data,
    baseURL: defaultSettings.apiCmsUrl
  })
}

/**
   * 获取所有可用的应用
   */
export function GetAllEnable() {
  return http.request({
    url: 'ad/GetAllEnable',
    method: 'get',
    baseURL: defaultSettings.apiCmsUrl // 直接通过覆盖的方式
  })
}
